package com.wp.service.impl;

import com.wp.mapper.FeedbackMapper;
import com.wp.pojo.FeedBack;
import com.wp.pojo.PageResult;
import com.wp.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FeedbackServiceImpl implements FeedbackService {
    @Autowired
    private FeedbackMapper feedbackMapper;
    /**
     * 获取反馈列表
     * */
    @Override
    public PageResult getFeedbackList(PageResult pageResult) {
//        pageResult.setStatus(1);
        Integer status= 1;
        Integer num= pageResult.getPageNum();
        Integer size= pageResult.getPageSize();
        String query=pageResult.getQuery();
        Integer startNum = (num-1)* size;
//        List<FeedBack> feedBacks= feedbackMapper.getFeedbackList(pageResult,startNum);
        List<FeedBack> feedBacks= feedbackMapper.getFeedbackList(query,status,startNum,size);
        System.out.println(feedBacks);
        Long total = feedbackMapper.getFeedbackCount(query,status);
        pageResult.setRows(feedBacks).setTotal(total);
        return pageResult;
    }
    /**
     * 删除反馈
     */
    public void deleteFeedback(FeedBack feedBack){
        Integer status = 0;
        String uid =feedBack.getUid();
        feedbackMapper.updateFeedback(uid,status);
    }
}
